package mailclient;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;

/**
 *
 * @author Vipar
 */
public class HotmailFetcher extends Fetcher {
    @SuppressWarnings("unchecked")
    public Message[] readHotmail() throws Exception {
        this.receivingHost = "pop3.live.com";
        Properties props = System.getProperties();
        props.setProperty("mail.pop3s.port", "995");
        Session session = Session.getDefaultInstance(props,null);
        Message message[] = null;
            store = session.getStore("pop3s");
            store.connect(receivingHost, 995, username, password);
            folder = store.getFolder("INBOX");
            folder.open(Folder.READ_ONLY);
            message = folder.getMessages();
            List<Message> list = Arrays.asList(message);
            Collections.reverse(list);
            
        return (Message[]) list.toArray();
    }
}
